<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">

   function add(form,btnId) {
	//form.buttonId[0].value = btnId;
	window.open("new.action","新規SG",
	            "status=yes,scrollbars=yes,resizable=yes");
	 }	 
   
   function checkDate(typeName)
{
    if(typeName=="検出日")
    {
	    var y= document.getElementById("test_date_y");
		var m = document.getElementById("test_date_m");
		var d = document.getElementById("test_date_d");
	}else{}
	if(typeName=="対応期限")
	{
		var y  =  document.getElementById("limit_date_y");
		var m  =  document.getElementById("limit_date_m");
		var d  = document.getElementById("limit_date_d");
    }else{}
    var check = /^(19|20)[0-9]{2}$/;
          
       if (check.test(y.value) == false)
        {
            alert(typeName+"_年を入力不正");
            return false;
        }
        else
        {
            
            if(m.value == 1 || m.value == 3 || m.value == 5 || m.value == 7 || m.value == 8 || m.value == 10 || m.value == 12)
            {
                if(d.value < 0 || d.value > 31)
                {
                    alert(typeName+"_日を選択不正");
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                if(m.value == 2)
                {
                    if(y.value % 400 == 0 || (y.value % 4 == 0 && y.value % 100 != 0))
                    {
                        if(d.value < 1 || d.value > 29)
                        {
                            alert(typeName+"_日を選択不正");
                            return false;
                        }
                        else
                        {
                            return true;
                        }
                    }
                    else
                    {
                        if(d.value < 1 || d.value > 28)
                        {
                            alert(typeName+"_日を選択不正");
                            return false;
                        }
                        else
                        {
                            return true;
                        }
                    }
                }
                else
                {
                    if(d.value < 1 || d.value > 30)
                    {
                        alert(typeName+"_日を選択不正");
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
            }
        } 
}

function dateCompare(d1,d2)
{
    if (Date.parse(d1) - Date.parse(d2) > 0)
    {
        	alert("対応期限が、検出日より過去日付になっているので修正して下さい。");
        return false;
    }
    else{
    	return true;
    }
}
 function formCheck(){
	var testDateY = document.getElementById("test_date_y");
	var testDateM = document.getElementById("test_date_m");
	var testDateD = document.getElementById("test_date_d");
	var limitDateY  =  document.getElementById("limit_date_y");
	var limitDateM  =  document.getElementById("limit_date_m");
	var limitDateD  = document.getElementById("limit_date_d");
	

	var testDate   =  testDateY.value+"/"+testDateM.value+"/"+testDateD.value;
	var limitDate  =  limitDateY.value+"/"+limitDateM.value+"/"+limitDateD.value;
	
    var ss=document.getElementById("projectId");
    var tema=document.getElementById("tema");
    var tl=document.getElementById("test_lvl");
    var tp=document.getElementById("test_part");
    var tester= document.getElementById("tester");
    var sta=document.getElementById("status");
    var memo=document.getElementById("memo");
    var et=document.getElementById("error_text");
    var qm=document.getElementById("qa_memo");
    var my=document.getElementById("modify");
     
     if(testDateY.value=="")
     {
     alert("検出日の年を入力下さい")
     return false;
     }
     if(testDateM.value=="")
     {
     alert("検出日の月を入力下さい")
     return false;
     }
     if(testDateD.value=="")
     {
     alert("検出日の日を入力下さい")
     return false;
     }
     if(!checkDate("検出日")) {
		return false;
	 }
     if(ss.value=="")
     {
     alert("プロジェクトを入力下さい")
     return false;
     }
     if(tema.value=="")
     {
     alert("所属テーマを入力下さい")
     return false;
     }
     if(tl.value=="")
     {
     alert("テスト段階を入力下さい")
     return false;
     }
     if(tp.value=="")
     {
     alert("検出側を入力下さい")
     return false;
     }
     if(tester.value=="")
     {
     alert("検出者を入力下さい")
     return false;
     }
     if(sta.value=="")
     {
     alert("ステータスを入力下さい")
     return false;}
     if(memo.value=="")
     {
     alert("概要を入力下さい")
     return false;
     }
     if(et.value=="")
     {
     alert("障害内容を入力下さい")
     return false;
     }
     if(limitDateY.value=="")
     {
     alert("対応期限の年を入力下さい")
     return false;
     }
     if(limitDateM.value=="")
     {
     alert("対応期限の月を入力下さい")
     return false;
     }
     if(limitDateD.value=="")
     {
     alert("対応期限の日を入力下さい")
     return false;
     }
     if(!checkDate("対応期限")) {
		return false;
	 }
	 if(my.value=="")
     {
     alert("対応担当者を入力下さい")
     return false;
     }
     if(qm.value=="")
     {
     alert("備考を入力下さい")
     return false;
     }
	if(!dateCompare(testDate,limitDate)) {
		return false;
	}
}

 </script>
    <style type="text/css">
	<!--
	body {
       font-family: Arial, Helvetica, sans-serif;
       font-size:12px;
      }
      fieldset {
         padding:10px;
         margin-top:5px;
         border:1px solid #A4CDF2;
         font-size:12px;
        }
      fieldset legend {
         font-weight:bold;
         font-size: 15px;          
       }
      div_footer{
       text-align:center;
      }
      .textfield{
         width:40px;
         color:#003366; 
         font-size:12px;
      }
      .textarea{
        color:#003366;
        font-size:12px;
      }
      .select{
      width:130px;
      border-right: #000000 1px solid;
      border-top: #ffffff 1px solid;
      border-left: #ffffff 1px solid;
      color:#003366;
      border-bottom: #000000 1px solid;
      background-color: #f4f4f4;
      font-size:12px;
    }
    .select_m{
      border-right: #000000 1px solid;
      border-top: #ffffff 1px solid;
      border-left: #ffffff 1px solid;
      color:#003366;
      border-bottom: #000000 1px solid;
      background-color: #f4f4f4;
      font-size:12px;
    }
    .btn1{
	   BORDER-RIGHT: #2C59AA 1px solid; 
	   PADDING-RIGHT: 2px; 
	   BORDER-TOP: #2C59AA 1px solid; 
	   PADDING-LEFT: 2px; 
	   FONT-SIZE: 12px; 
	   FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#C3DAF5); 
	   BORDER-LEFT: #2C59AA 1px solid; 
	   CURSOR: hand; 
	   COLOR: black; 
	   PADDING-TOP: 2px; 
	   BORDER-BOTTOM: #2C59AA 1px solid;
	}
     -->
 </style>
<title>新規SG</title>
</head>
<body text=#003366 onload="init();">
<s:form method="POST">
<fieldset>
<legend>新規SG</legend>
<table width=70% align="center">
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">検出日</td>
              <td align="left" style="font-size:12px;">
      <s:textfield id="test_date_y" name ="sgnew.test_date_y" labelposition = "right" theme = "simple" size="2" maxlength="4" cssClass="textfield"/>年
      <s:select id="test_date_m"  name="sgnew.test_date_m" theme ="simple" headerKey="" headerValue="" list="monthArray"  value="sgnew.test_date_m" cssClass="select_m"/>月
	  <s:select id="test_date_d"  name="sgnew.test_date_d" theme ="simple" headerKey="" headerValue="" list="dayArray"  value="sgnew.test_date_d" cssClass="select_m"/>日
	   </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>              
              <td width=30% style="font-size:12px;">プロジェクト</td>
              <td align="left">
              <s:select theme="simple" cssClass="select" id="projectId" name="sgnew.projectId" headerKey="" headerValue="" list="projectList" listKey="projectId" listValue="projectName" value="search.projectId" />
       	    </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
                <td width=30% style="font-size:12px;">所属テーマ</td>
              <td align="left">
              <s:select theme="simple" cssClass="select" id="tema" name="sgnew.tema" headerKey="" headerValue="" list="functionArray" listKey="theme_id" listValue="theme_name" value="search.tema" />
              </td>
          </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">テスト段階</td>
              <td align="left">
        <s:select id="test_lvl" name="sgnew.test_lvl" cssClass="select"  headerKey="" headerValue="" list="testlvlArray" listKey="master_value" listValue="master_value" theme = "simple" value="sgnew.test_lvl" />				
					</td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">検出側</td>
              <td align="left">
         <s:select id="test_part" name="sgnew.test_part" theme ="simple" headerKey="" 
         headerValue="" list="testPartArray" listKey="master_value" listValue="master_value" 
         value="sgnew.test_part" cssClass="select"/> 
	     	</td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
     <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">検出者</td>
              <td align="left" style="font-size:12px;">
         <s:select id="tester" name="sgnew.tester" cssClass="select"  theme ="simple" headerKey="" headerValue="" list="testerArray" listKey="user_disp_value" listValue="user_disp_value" value="sgnew.tester"/> 
			</td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">ステータス</td>
              <td align="left">
       <s:select id="status" name="sgnew.status" cssClass="select" theme ="simple" headerKey="" headerValue="" list="statusArray" listKey="master_value" listValue="master_value" value="sgnew.status"/> 
                </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>  
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">概要</td>
              <td align="left">
					<textarea rows=4 cols=50 id="memo" name="sgnew.memo" cssClss="textarea"></textarea></td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">障害内容</td>
              <td align="left">
					<textarea rows=4 cols=50 id="error_text" name="sgnew.error_text" cssClss="textarea"></textarea></td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">対応期限</td>
              <td align="left" style="font-size:12px;">
     <s:textfield id="limit_date_y" name ="sgnew.limit_date_y" labelposition = "right" theme = "simple" size="2" maxlength="4" cssClass="textfield"/>年
      <s:select id="limit_date_m" name="sgnew.limit_date_m" theme ="simple" headerKey="" headerValue="" list="monthArray"  value="limit_date_m" cssClass="select_m"/>月
	  <s:select id="limit_date_d" name="sgnew.limit_date_d" theme ="simple" headerKey="" headerValue="" list="dayArray"  value="sgnew.limit_date_d" cssClass="select_m"/>日
	   </td>
         </tr>
         </table>
     <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">対応担当者</td>
              <td align="left" style="font-size:12px;">
         <s:select id="modify" name="sgnew.modify" cssClass="select"  theme ="simple" headerKey="" headerValue="" list="modifyArray" listKey="user_disp_value" listValue="user_disp_value" value="sgnew.modify"/> 
	   </td>
         </tr>
         </table>
    </td>
    </tr>
    <tr>
    <td bgcolor=RGB(221,230,247)>
         <table width=100%>
         <tr>
              <td width=30% style="font-size:12px;">備考</td>
              <td align="left">
					<textarea rows=4 cols=50 id="qa_memo" name="sgnew.qa_memo" cssClass="textarea"></textarea></td>
         </tr>
         </table>
    </td>
    </tr>
    </table>

</fieldset>
<table cellspacing="5" summary="隙間用">
  <tr><td></td></tr>
  <tr><td></td></tr>
  <tr><td></td></tr></table>
	<table cellpadding="0" cellspacing="0" width="100%" bgcolor=RGB(238,242,251)>
		<tr>
		　<td align = "center" width="20%">
		　　　<s:submit btnId="D012" theme="simple"  value="戻    　 る" action="listSG" cssClass="btn1"/>	
		 </td>  
		 <td align = "center" width="20%">				
        <s:submit btnId="D013"  action="insertSG" theme="simple" value = "完      了" onclick="return formCheck()" cssClass="btn1"/>                  
         </td>   
		</tr>  
	</table>                 
</s:form>         	    
</body>
</html>